//
//  HMSerachView.swift
//  SinaWeibo
//
//  Created by apple on 16/9/22.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

//在自定义控件的声明的前面添加 @IBDesginable
@IBDesignable class HMSerachView: UIButton {
    
    //@IBAction
    //@IBOutlet
    //@IBInspectable 定义可视化属性
    //@IBDesignable 让可视化属性时时刷新
    
    
    //定义类方法 加载该视图的nib文件
    class func loadSearchView() -> HMSerachView{
        let nib = UINib(nibName: "HMSearchView", bundle: nil)
        let searchView = nib.instantiate(withOwner: nil, options: nil).last as! HMSerachView
        return searchView
    }

    //当视图被激活的时候
    override func awakeFromNib() {
        //设置图片的内边距
        self.imageEdgeInsets = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 0)
        //设置文字的内边距
        self.titleEdgeInsets = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 0)
        //通过代码的方式设置宽度
        self.bounds.size.width = UIScreen.main.bounds.width
        
        //设置圆角
        //self.layer.cornerRadius = 17
        //控件默认
        //self.layer.masksToBounds = true
        
    }
    
}
